package com.etone.smartAudit.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class CpuUserService {

    /**
     * 占用cpu
     */
    public void useCpu(int second) {
        CPUTestThread cpuTestThread = new CPUTestThread();
        for (int i = 0; i < 50; i++) {
            Thread cpuTest = new Thread(cpuTestThread);
            cpuTest.start();
        }
        try {
            Runtime.getRuntime().exec("taskmgr");
        } catch (Exception e) {
            e.printStackTrace();
        }
        cpuTestThread.setStopCpu(true);
    }

    /***
     * 启动
     */
    public void start() {
//        useCpu();
    }

    /***
     * 停止
     */
    public void stop() {
    }

    public static void main(String[] args) throws Exception {
        CpuUserService service = new CpuUserService();
        service.useCpu(100);
    }
}

